'use strict';

module.exports = app => {
    const { Sequelize, model } = app

    const Model = model.define('minaDriverApply', {
        id:{
            type: Sequelize.STRING.BINARY,
            defaultValue: Sequelize.UUIDV1,
            primaryKey: true
        },
        familyName: {
            type: Sequelize.STRING(20),
            allowNull: false
        },
        givenName: {
            type: Sequelize.STRING(20),
            allowNull: false
        },
        phone: {
            type: Sequelize.STRING(20),
            allowNull: false
        },
        liceType: {
            type: Sequelize.STRING(10),
        },
        drivingLiceUrl: {
            type: Sequelize.STRING,
            allowNull: false
        },
        serviceArea: {
            type: Sequelize.STRING,
        },
        bankName: {
            type: Sequelize.STRING(30),
        },
        bankCard: {
            type: Sequelize.STRING(30),
        },
        bankCode: {
            type: Sequelize.STRING(10),
        },
        auditor: {
            type: Sequelize.STRING(20),
        },
        remark: {
            type: Sequelize.STRING(20),
        },
        status: {
            type: Sequelize.INTEGER(2),
            defaultValue: 0,
            allowNull: false,
        },
    }, {
        freezeTableName: true,
        tableName: 'mina_driver_apply',
        timestamps: true,
        paranoid: true,
    })

    Model.associate = function() {
        model.MinaDriverApply.belongsTo(model.MinaDriver)
        model.MinaDriver.hasMany(model.MinaDriverApply)
    }

    return Model
}